package byteStream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class test_input {
    public static void main(String[] args) throws IOException {
       singleRead();

    }

    private static void allRead() throws IOException {
        FileInputStream fileInputStream=new FileInputStream("D:\\java\\JavaMaterial\\1.txt");
        byte[] byt=new byte[2];
        int i;
        while ( (i=fileInputStream.read(byt))!=-1){
            //将字符数组变成字符串
            String str=new String(byt,0,i);
            System.out.println(str);
        }
        fileInputStream.close();
    }

    private static void singleRead() throws IOException {
        FileInputStream fis=new FileInputStream("D:\\java\\JavaMaterial\\1.txt");
        //读取一个
        int j=fis.read();
        System.out.println((char)j);
        //循环读取
        int i;
        while ((i=fis.read())!=-1){
            System.out.println((char)i );
        }
        fis.close();
    }
}
